import request from '@/config/axios'

// 员工工资 VO
export interface EmployeeSalaryVO {
  id: number // 主键ID
  years: number // 年份
  month: number // 月份
  userId: number // 员工ID
  userName: string // 员工姓名
  company: string // 公司
  baseSalary: number // 基本工资
  positionSalary: number // 岗位工资
  salarySubtotal: number // 工资小计
  attendanceDays: number // 考勤天数
  publicHolidayCompensatoryLeave: number // 公休/调休
  sickLeave: number // 病假
  personalLeave: number // 事假
  otherLeave: number // 其他
  maternityCheckupLeave: number // 产检假
  deductionAmount: number // 扣除金额
  actualAttendanceDays: number // 出勤天数
  weekdayOvertime: number // 平日加班
  weekendOvertime: number // 双休日加班
  holidayOvertime: number // 节假日加班
  overtimePay: number // 加班费
  lateEarlyDeduction: number // 迟到早退
  errorOmission: number // 错漏
  otherDeductions: number // 其他扣款
  adjustedSalary: number // 调整工资
  performanceSalary: number // 绩效工资
  businessTripAllowance: number // 出差津贴
  highTemperatureAllowance: number // 高温补贴
  adjustedSocialSecurityDeduction: number // 调整社保(扣)
  expatriateAllowance: number // 外派补贴
  otherAllowance: number // 其他
  payrollReviewSubtotal: number // 核薪小计
  individualBasicEndowmentInsurance: number // 个人缴纳基本养老保险费
  individualBasicMedicalInsurance: number // 个人缴纳基本医疗保险费
  individualUnemploymentInsurance: number // 个人缴纳失业保险费
  individualSocialSecuritySubtotal: number // 个人社保缴纳小计
  companySocialSecurityContribution: number // 公司社保缴纳
  individualHousingFund: number // 个人公积金缴纳
  companyHousingFund: number // 公司公积金缴纳
  payableSalary: number // 应付工资
  individualIncomeTax: number // 个调税
  grossSalaryPayable: number // 应发工资
  mealAllowance: number // 餐补
  transportationAllowance: number // 交补
  otherFinal: number // 其他
  totalAmount: number // 合计
  publishStatus: number // 发布状态(0:未发布,1:已发布)
}

// 员工工资分页查询 Request VO
export interface EmployeeSalaryPageReqVO extends PageParam {
  years?: number // 年份
  month?: number // 月份
  userId?: number // 员工ID
  userName?: string // 员工姓名
  publishStatus?: number // 发布状态(0:未发布,1:已发布)
  createTime?: Date[] // 创建时间
}

// 员工工资创建/修改 Request VO
export interface EmployeeSalarySaveReqVO {
  id?: number // 主键ID
  years: number // 年份
  month: number // 月份
  userId: number // 员工ID
  userName: string // 员工姓名
  company?: string // 公司
  baseSalary?: number // 基本工资
  positionSalary?: number // 岗位工资
  salarySubtotal?: number // 工资小计
  attendanceDays?: number // 考勤天数
  publicHolidayCompensatoryLeave?: number // 公休/调休
  sickLeave?: number // 病假
  personalLeave?: number // 事假
  otherLeave?: number // 其他
  maternityCheckupLeave?: number // 产检假
  deductionAmount?: number // 扣除金额
  actualAttendanceDays?: number // 出勤天数
  weekdayOvertime?: number // 平日加班
  weekendOvertime?: number // 双休日加班
  holidayOvertime?: number // 节假日加班
  overtimePay?: number // 加班费
  lateEarlyDeduction?: number // 迟到早退
  errorOmission?: number // 错漏
  otherDeductions?: number // 其他扣款
  adjustedSalary?: number // 调整工资
  performanceSalary?: number // 绩效工资
  businessTripAllowance?: number // 出差津贴
  highTemperatureAllowance?: number // 高温补贴
  adjustedSocialSecurityDeduction?: number // 调整社保(扣)
  expatriateAllowance?: number // 外派补贴
  otherAllowance?: number // 其他
  payrollReviewSubtotal?: number // 核薪小计
  individualBasicEndowmentInsurance?: number // 个人缴纳基本养老保险费
  individualBasicMedicalInsurance?: number // 个人缴纳基本医疗保险费
  individualUnemploymentInsurance?: number // 个人缴纳失业保险费
  individualSocialSecuritySubtotal?: number // 个人社保缴纳小计
  companySocialSecurityContribution?: number // 公司社保缴纳
  individualHousingFund?: number // 个人公积金缴纳
  companyHousingFund?: number // 公司公积金缴纳
  payableSalary?: number // 应付工资
  individualIncomeTax?: number // 个调税
  grossSalaryPayable?: number // 应发工资
  mealAllowance?: number // 餐补
  transportationAllowance?: number // 交补
  otherFinal?: number // 其他
  totalAmount?: number // 合计
  publishStatus?: number // 发布状态(0:未发布,1:已发布)
}

// 员工工资 API
export const EmployeeSalaryApi = {
  // 创建员工工资
  createEmployeeSalary: (data: EmployeeSalarySaveReqVO) => {
    return request.post({ url: '/oa/employee-salary/create', data })
  },
  // 更新员工工资
  updateEmployeeSalary: (data: EmployeeSalarySaveReqVO) => {
    return request.put({ url: '/oa/employee-salary/update', data })
  },
  // 删除员工工资
  deleteEmployeeSalary: (id: number) => {
    return request.delete({ url: '/oa/employee-salary/delete?id=' + id })
  },
  // 获得员工工资
  getEmployeeSalary: (id: number) => {
    return request.get({ url: '/oa/employee-salary/get?id=' + id })
  },
  // 获得员工工资分页
  getEmployeeSalaryPage: (params: EmployeeSalaryPageReqVO) => {
    return request.get({ url: '/oa/employee-salary/page', params })
  },
  // 导出员工工资 Excel
  exportEmployeeSalary: (params: EmployeeSalaryPageReqVO) => {
    return request.download({ url: '/oa/employee-salary/export-excel', params })
  },
  // 导入员工工资 Excel
  importEmployeeSalary: (data: FormData) => {
    return request.upload({ url: '/oa/employee-salary/import-excel', data })
  },
  // 下载员工工资 Excel 导入模板
  downloadImportTemplate: () => {
    return request.download({ url: '/oa/employee-salary/import-template' })
  },
  // 更新员工工资发布状态
  updatePublishStatus: (id: number, publishStatus: number) => {
    return request.put({ url: '/oa/employee-salary/publish', params: { id, publishStatus } })
  },
  // 批量更新员工工资发布状态
  batchUpdatePublishStatus: (ids: number[], publishStatus: number) => {
    return request.put({ url: '/oa/employee-salary/batch-publish', data: { ids, publishStatus } })
  }
}
